<?php
	$css_list[0]['url'] = './tpl/css/article.css';
?>
<!--{template inc/header_n}-->

<div class="main_warp">
    <div class="inventory">
        <!--{template inc/list/list_menu}-->

        <div class="i_righter">
            <div class="robot" id="robot">
                <div class="i_box">
                    <div class="i_title">与<span>婚礼君</span>聊天中</div>
                    <div id="swrap" class="i_list">
                        <ul id="wrap">
                        {if !empty($logs)}
                            {loop $logs $v}
                            {if !empty($v['ask'])}
                            <li>
                                <div class="j_time">{$v['dateline']}</div>
                                <div class="j_me">
                                    <img src="{avatar $_FANWE['user']['avatar'] m}" class="k_img">
                                    <div class="k_body">
                                        <div class="k_content"><p>{$v['ask']}</p></div>
                                        <div class="arrow"></div>
                                    </div>
                                    <div class="g_clear"></div>
                                </div>
                            </li>
                            {/if}
                            <li>
                                <div class="j_robot">
                                    <img src="/public/upload/avatar/noavatar_middle.jpg" class="k_img">
                                    <div class="k_body">
                                        <div class="k_content"><p>{$v['answer']}</p></div>
                                        <div class="arrow"></div>
                                    </div>
                                    <div class="g_clear"></div>
                                </div>
                            </li>
                            {/loop}
                        {/if}    
                        </ul>
                    </div>
                    <div class="i_post">
                        <input type="text" id="ask" class="g_ipt1" size="64" placeholder="试试搜索‘案例 和你想吃的火锅‘"/>
                        <input type="button" onclick="doask()" value="发送" class="g_btn1" />
                    </div>
                </div>
            </div>
            
            <div class="tags_cloud" id="tags_cloud">
                <div class="i_close" onclick="showTagCloud(false)">×</div>
                <iframe src="/services/service.php?m=u&a=tagcloud" width="780" height="800"></iframe> 
            </div>
            
            <div class="i_notice" style="top:0px;">
                <div class="j_title">公告栏</div>
                <div class="j_list">
                    <ul>
             <li><a href="#"><b>婚礼款项建设银行冻结监管</b></a></li>
             <li><a href="#"><b>真实新人评价（新人凭婚宴发票进行评价）</b></a></li>
             <li><a href="#"><b>没有中间商赚差价</b></a></li>
                    </ul>
                </div>
            </div>
        </div>
        <br class="g_clear" />
    

    <div class="huoguojun" id="huoguojun" onclick="showTagCloud(true)"><img src="/public/v1/img/huoguojun.png"></div>

    </div>

</div>



<!--{template inc/footer}-->
<script type="text/javascript">
$("#ivtList .j_a").click( function () {
    if( $(this).next('.j_info').is(":visible") ){
        $(this).next('.j_info').hide();
        $(this).children('.j_s').show();
    }else{
        $("#ivtList .j_info").hide();
        $("#ivtList .j_s").show();
        $(this).next('.j_info').show();
        $(this).children('.j_s').hide();
    }
});

$("#ivtList .j_btn").click( function () {
    $("#ivtList .j_info").hide();
    $(this).parent().parent().find('.j_s').show().addClass("j_s_yes").html("已完成");
});

$("#ivtList li:eq(0) .j_info").show();

function doread(id) {
    $.get('/list.php?action=doread&id='+id, function(s){
        $('#doread_'+id).remove();
        if($('[name="doread"]').length == 0) {
            $('#tip').html('已全部完成');
        }
    })
}

function doask() {
    var askstr = $('#ask').val();
    myask(askstr);
}

function myask(askstr) {
    var date = new Date();
    var hour = date.getHours();
    hour = hour > 9 ? hour : '0' + hour;
    var min = date.getMinutes();
    min = min > 9 ? min : '0' + min;
    var datestr = hour + ':' + min;
    if(askstr != '') {
        $('#wrap').append('<li><div class="j_time">'+datestr+'</div><div class="j_me"><img src="{avatar $_FANWE['user']['avatar'] m}" class="k_img"><div class="k_body"><div class="k_content"><p>'+askstr+'</p></div><div class="arrow"></div></div><div class="g_clear"></div></div></li>');
        
        $.post('/list.php?action=robot', {doask:true, ask:askstr}, function(s) {
            $('#wrap').append('<li><div class="j_robot"><img src="/public/upload/avatar/noavatar_middle.jpg" class="k_img"><div class="k_body"><div class="k_content"><p>'+s+'</p></div><div class="arrow"></div></div><div class="g_clear"></div></div></li>');
            $('#ask').val('');
            var div = document.getElementById('swrap');
            div.scrollTop = div.scrollHeight;
        });
    }
}

function suggest(aid, tipid) {
    $.post('/list.php?action=robot', {doask:true, ask:'',aid:aid, tipid:tipid}, function(s) {
        $('#wrap').append('<li><div class="j_robot"><img src="/public/upload/avatar/noavatar_middle.jpg" class="k_img"><div class="k_body"><div class="k_content"><p>'+s+'</p></div><div class="arrow"></div></div><div class="g_clear"></div></div></li>');
        var div = document.getElementById('swrap');
        div.scrollTop = div.scrollHeight;
    });
}

function docomplete(id, obj) {
    $(obj).attr('disabled', true);
    $.post('/list.php?action=robot', {docomplete:true, id:id}, function(s) {
        //alert(s);
    });
}

$(window).keypress(function(event){
    if(event.keyCode == 13) {
        doask();
    }
});

$(function() {
    var div = document.getElementById('swrap');
    div.scrollTop = div.scrollHeight;
});

{if false && $_FANWE['user']['showfeedback'] == 0}
var is_first=0;

var UnloadConfirm = {};
UnloadConfirm.MSG_UNLOAD = "您可以给我们留言或者选择离开此页！";
UnloadConfirm.set = function(a) {
    window.onbeforeunload = function(b) {
        if(is_first>0){
            $.weeboxs.open(SITE_PATH+"services/service.php?m=u&a=feedback",{boxid:'ZONE_FOLLOW_WEEBOX',contentType:'ajax',draggable:false,showButton:false,showTitle:false,showHeader:false,width:640,height:800});
        }
        b = b || window.event;
        b.returnValue = a;
        return a;
    }
};
UnloadConfirm.clear = function() {
    window.onbeforeunload = function() {}
};

UnloadConfirm.set(UnloadConfirm.MSG_UNLOAD);
is_first++;

/*
var EventUtil = {
    getEvent: function (event) {
        return event ? event : window.event;
    },
    addHandler: function (element, type, handler) {
        if (element.addEventListener) {
            element.addEventListener(type, handler, false);
        } else if (element.attachEvent) {
            element.attachEvent("on" + type, handler);
        } else {
            element["on" + type] = handler;
        }
    }
};
EventUtil.addHandler(window, "beforeunload", function (event) {
    event = EventUtil.getEvent(event);
    event.returnValue = "如果你离开，我真的会想念你。";
});
*/
{/if}

function showTagCloud(onff){
    if(onff){
        $("#huoguojun").hide();
        $("#robot").hide();
        $("#tags_cloud").show();
    }else{
        $("#huoguojun").show();
        $("#robot").show();
        $("#tags_cloud").hide();
    }
}

//{if isset($_GET['new'])}
////$.weeboxs.open(SITE_PATH+'services/service.php?m=index&a=guide',{boxid:'ZONE_FOLLOW_WEEBOX',contentType:'ajax',draggable:false,showButton:false,showTitle:false,showHeader:false,width:800,height:600});
//$.colorbox({
//    href:SITE_PATH+'services/service.php?m=index&a=guide',
//    width:800,
//    height:600
//});
//{/if}
</script>